<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            height: 600px;
            width: 600px;
            border: solid;
            margin-left: 100px;
            margin-top: 100px;
        }

        .ball {
            position: fixed;
            height: 100px;
            width: 100px;
            background: grey;
            top: 0;
            left: 0;
        }
    </style>
</head>

<body>
    <div class="box" id="box">
        <div id="ball" class="ball"></div>
    </div>
    <script>
        const box = document.getElementById('box');
        const ball = document.getElementById('ball');


        box.onclick = function (e) {
            ball.style.left = e.pageX + 'px';
            ball.style.top = e.pageY + 'px';
        }

    </script>
</body>

</html>